namespace Digitalmes.Application.Sys.Configs.Queries;

/// <summary>
/// 系统配置分页查询命令
/// </summary>
public record GetConfigListWithPagedQuery(
    int PageNumber,
    int PageSize) : IPagedQuery, IRequest<IResult<PagedList<SysConfigDto>>>;

public sealed class GetConfigListWithPagedQueryHandler(IRepository<SysConfig> repo) : IRequestHandler<GetConfigListWithPagedQuery, IResult<PagedList<SysConfigDto>>>
{
    public async Task<IResult<PagedList<SysConfigDto>>> Handle(GetConfigListWithPagedQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetPagedListAsync(request.PageNumber, request.PageSize, cancellationToken);
        return Result.From(items.Adapt<PagedList<SysConfigDto>>());
    }
}
